package com.example.pojo;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.List;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class Result<T>{
    // 返回的状态码：200成功； 500失败
    private Integer code;
    // 返回的提示内容
    private String msg;
    // 返回的数据
    private T obj;

    // 操作成功
    public static <T> Result<T> ok() {
        return new Result<>(200,"操作成功!",null);
    }
    public static <T> Result<T> ok(T obj,String smg) {
        return new Result<>(200,smg,obj);
    }
    public static <T> Result<T> ok(T obj) {
        return new Result<>(200,"",obj);
    }
    public static <T> Result<T> ok( String msg) {
        return new Result<>(200,msg,null);
    }
    public static <T> Result<T> ok(T obj,String msg,Integer code) {
        return new Result<>(code, msg, obj);
    }
    // 操作失败
    public static <T> Result<T> fail() {
        return new Result<>(500,"操作失败!",null);
    }
    public static <T> Result<T> fail(String msg,Integer code) {
        return new Result<>(500,msg,null);
    }


//    public static Result success(List<Log> logs) {
//        return null;
//    }
}
